package com.example.thirdhomework

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.thirdhomework.databinding.ActivityFirstBinding

class FirstActivity : AppCompatActivity() {
    private val binding by lazy{
        ActivityFirstBinding.inflate(layoutInflater)
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
       setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(binding.main) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.TIRAMISU){
            intent.getSerializableExtra(KEY1,Student::class.java)?.let {
                binding.textView.text=it.toString()
            }
        }else{
            (intent.getSerializableExtra(KEY1) as? Student)?.let{
                binding.textView.text=it.toString()
            }
        }
        binding.button2.setOnClickListener{
            finish()
        }
    }
}